<template>
  <div class="app-container">
    <div class="head_search u-f u-f-ac u-fw border_bottom">
      <div class="ipt_box u-f u-f-ac u-f-jsb">
        <p class="label font14 text_black">{{ $t("商铺名称") }}：</p>
        <el-input v-model="merchant" :placeholder="$t('请输入商铺名称')"></el-input>
      </div>
      <div class="ipt_box u-f u-f-ac u-f-jsb">
        <p class="label font14 text_black">{{ $t("所在区域") }}：</p>
        <el-input v-model="address" :placeholder="$t('请输入所在区域')"></el-input>
      </div>
      <div class="div_box u-f u-f-ac">
        <p class="label font14 text_black">{{ $t("所属代理商") }}：</p>
        <div class="content font14 text_black u-f u-f-ac" @click="openAgentList">
          <p class="text-ellipsis">{{ agent ? agent : $t("选择代理商") }}</p>
        </div>
        <button class="btn font14 text_white bg_danger" @click="clearAgent">{{ $t("清除") }}</button>
      </div>
      <div class="div_box u-f u-f-ac">
        <p class="label font14 text_black">{{ $t("商户管理") }}：</p>
        <div class="content font14 text_black u-f u-f-ac" @click="openManageList(1)">
          <p class="text-ellipsis">{{ manage ? manage : $t("选择商户管理") }}</p>
        </div>
        <button class="btn font14 text_white bg_danger" @click="clearManage(1)">{{ $t("清除") }}</button>
      </div>
      <div class="select_box u-f u-f-ac u-f-jsb" style="width: 260px;">
        <p class="label font14 text_black">{{ $t("状态") }}：</p>
        <el-select v-model="clientVal" :placeholder="$t('请选择')" @change="clientChange">
          <el-option
            v-for="item in clientArr"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </div>
      <div class="select_box u-f u-f-ac u-f-jsb" style="width: 290px;">
        <p class="label font14 text_black">{{ $t("所属业务员") }}：</p>
        <el-select v-model="salesmanVal" :placeholder="$t('请选择')" @change="salesmanChange">
          <el-option v-for="item in salesmanArr" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </div>
      <button class="sub_btn font14 text_white bg_blue" @click="getData('search')">{{ $t("提交") }}</button>
    </div>

    <div class="head_options u-f u-f-ac u-fw">
      <button
        class="sub_btn font14 text_white bg_blue"
        @click="addCabinet"
        v-if="permissions.indexOf('/seller/add') != -1"
      >{{ $t("添加商户") }}</button>
    </div>

    <div>
      <el-table :data="tableData">
        <el-table-column prop="name" :label="$t('商铺名称')"></el-table-column>
        <el-table-column prop="brokerage" :label="$t('佣金比')">
          <template slot-scope="{ row }">
            <span>{{ row.brokerage }}%</span>
          </template>
        </el-table-column>
        
        <el-table-column prop="agency" :label="$t('代理商')"></el-table-column>
        <el-table-column prop="employee" :label="$t('业务员')"></el-table-column>
        <el-table-column prop="manager_name" :label="$t('商户管理')"></el-table-column>
        <el-table-column prop="area" :label="$t('所在区域')"></el-table-column>
        <el-table-column prop="address" :label="$t('详细地址')"></el-table-column>
        <el-table-column prop="tel" :label="$t('电话')"></el-table-column>
        <el-table-column prop="create_time" :label="$t('创建时间')" width="180"></el-table-column>
        <el-table-column prop="status" :label="$t('状态')"></el-table-column>
        <el-table-column :label="$t('操作')" width="180" fixed="right">
          <template slot-scope="scope">
            <button
              v-if="permissions.indexOf('/equipment/index') != -1"
              class="table_btn font12 bg_blue text_white"
              style="margin-right: 20px;margin-bottom: 10px;"
              @click="deviceDetail(scope.row)"
            >{{ $t("所属设备") }}</button>
            <button
              v-if="permissions.indexOf('/seller/edit') != -1"
              class="table_btn font12 bg_blue text_white"
              style="margin-bottom: 10px;"
              @click="updateDevice(scope.row)"
            >{{ $t("修改") }}</button>
            <button
              class="table_btn font12 bg_blue text_white"
              style="margin-bottom: 10px;"
              @click="addSpecial(scope.row)"
            >{{ $t("添加特殊用户") }}</button>
            <button
              v-if="permissions.indexOf('/seller/trend') != -1"
              class="table_btn font12 bg_blue text_white"
              style="margin-right: 20px;"
              @click="statistics(scope.row)"
            >{{ $t("租借统计") }}</button>
            <button
              v-if="permissions.indexOf('/seller/delete') != -1"
              class="table_btn font12 bg_danger text_white"
              @click="deleteCanTab(scope.row)"
            >{{ $t("删除") }}</button>
          </template>
        </el-table-column>
      </el-table>

      <div class="pagination_box">
        <el-pagination
          background
          
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-size="page_size"
          layout="total, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>

    <el-dialog
      width="1000px"
      :title="$t('修改特殊用户')"
      :visible.sync="updateSpecial"
      :close-on-click-modal="false"
      @close="guanbi"
    >
    
    <div class="order_detail">
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("充氧宝免费时长/分钟/每次") }}：</span>
          </p>
          <el-input v-model="addSpecialData.battery_free" :placeholder="$t('请输入充氧宝免费时长')"></el-input>
        </div>
        <!-- <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("充氧宝已免费时长") }}：</span>
          </p>
          <el-input v-model="addSpecialData.battery_use" :placeholder="$t('充氧宝已免费时长')"></el-input>
        </div> -->

        <!-- <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("每次免费时长") }}：</span>
          </p>
          <el-input v-model="addSpecialData.per_hour" :placeholder="$t('请输入每次免费时长小时')"></el-input>
        </div> -->
        <!-- <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("会员ID") }}：</span>
          </p>
          <el-input v-model="addSpecialData.member_id" :placeholder="$t('请输入会员ID')"></el-input>
        </div> -->
        
        <button
          class="sub_btn font14 text_white bg_blue"
          @click="updateSubmitSpecial"
        >{{ $t("修改") }}</button>
    </div>
    </el-dialog>

    <el-dialog
      width="1000px"
      :title="$t('添加特殊用户')"
      :visible.sync="cabSpecial"
      :close-on-click-modal="false"
    >
    
    <div class="order_detail">
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("充氧宝免费时长/分钟/每次") }}：</span>
          </p>
          <el-input v-model="addSpecialData.battery_free" :placeholder="$t('请输入充氧宝免费时长')"></el-input>
        </div>
        <!-- <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("每次免费时长") }}：</span>
          </p>
          <el-input v-model="addSpecialData.per_hour" :placeholder="$t('请输入每次免费时长小时')"></el-input>
        </div> -->
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("会员ID") }}：</span>
          </p>
          <el-input v-model="addSpecialData.member_id" :placeholder="$t('请输入会员ID')"></el-input>
        </div>
        
        <button
          class="sub_btn font14 text_white bg_blue"
          @click="addSubmitSpecial"
        >{{ $t("提交") }}</button>
    </div>

    <div class="order_detail">
      <el-table :data="tableDataSpecial">
        <el-table-column prop="id" :label="$t('ID')"></el-table-column>
        <el-table-column prop="member_id" :label="$t('会员id')"></el-table-column>
        <el-table-column prop="nick" :label="$t('用户名')"></el-table-column>
        <el-table-column :label="$t('操作')" width="180" fixed="right">
          <template slot-scope="scope">
            <button
              class="table_btn font12 bg_blue text_white"
              style="margin-bottom: 10px;"
              @click="updateCanTab1(scope.row)"
            >{{ $t("修改") }}</button>
              <button
                class="table_btn font12 bg_danger text_white"
                @click="deleteCanTab1(scope.row)"
              >{{ $t("删除") }}
              </button>
          </template>
        </el-table-column>
<!--         
        <button
          class="table_btn font12 bg_danger text_white"
          @click="deleteCanTab(scope.row)"
        >{{ $t("删除") }}
        </button> -->

      </el-table>
<!-- 
      <div class="pagination_box">
        <el-pagination
          background
          
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-size="page_size"
          layout="total, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div> -->
    </div>
      <!-- uid: that.data.uid,
      seller_ids: that.data.seller_ids.join(','),
      battery_free: that.data.battery_free,
      wired_free: that.data.wired_free,
      per_hour:that.data.per_hour -->
    </el-dialog>

    <!-- 添加和修改商户 -->
    <el-dialog
      width="1000px"
      :title="updateCab ? $t('修改商户') : $t('添加商户')"
      :visible.sync="showAddCab"
      :close-on-click-modal="false"
    >
      <div class="order_detail">
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("商铺名称") }}：</span>
          </p>
          <el-input v-model="addMerFrom.merchant" :placeholder="$t('请输入商铺名称')"></el-input>
        </div>
        <div class="div_box u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("商户管理") }}：</span>
          </p>
          <div class="content font14 text_black u-f u-f-ac" @click="openManageList(2)">
            <p class="text-ellipsis">{{ addMerFrom.manage ? addMerFrom.manage : $t("选择商户管理") }}</p>
          </div>
          <button class="btn font14 text_white bg_danger" @click="clearManage(2)">{{ $t("清除") }}</button>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("所属代理") }}：</span>
          </p>
          <el-input v-model="addMerFrom.agent" disabled></el-input>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("所属业务员") }}：</span>
          </p>
          <el-input v-model="addMerFrom.salesman" disabled></el-input>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("业务员佣金比") }}：</span>
          </p>
          <el-input v-model="addMerFrom.salesman_rate" :placeholder="$t('请输入业务员佣金比')"></el-input>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("商户佣金比例") }}：</span>
          </p>
          <el-input v-model="addMerFrom.manage_rate" :placeholder="$t('请输入商户佣金比例')"></el-input>
          <p class="tip font14 text_danger">
            {{ $t("商铺") }}+{{ $t("业务员")
            }}{{ $t("佣金必须是小于所属代理商分成比") }}（{{
            addMerFrom.agent_rate
            }}）{{ $t("的整数") }},{{ $t("单位") }}%
          </p>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("商户分成系数比") }}：</span>
          </p>
          <el-input v-model="addMerFrom.brokerage_rate" :placeholder="$t('请输入')"></el-input>
          <p class="tip font14 text_danger">{{ $t("商户分成系数比") }}：0-100</p>
        </div>
        <p class="tip font14 text_danger">{{ $t("商户实际比例为") }}：{{ $t("商户佣金比") }} * {{ $t("分成系数比") }}, {{ $t("如") }}：70*80 = 56%</p>
        <!-- <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("列表显示比例") }}：</span>
          </p>
          <el-input v-model="addMerFrom.brokerage_show" :placeholder="$t('请输入')"></el-input>
          <p class="tip font14 text_danger">{{ $t("商户列表中显示的商户比例") }}</p>
        </div> -->

        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("所在区域") }}：</span>
          </p>
          <el-cascader
            v-model="addMerFrom.areaCode"
            :options="regionArr"
            @change="handleAreaChange"
            clearable
          ></el-cascader>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("地址") }}：</span>
          </p>
          <el-input v-model="addMerFrom.address" @change="enterAddress" :placeholder="$t('请输入地址')"></el-input>
        </div>
        <div class="txt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("经纬度") }}：</span>
          </p>
          <span class="font14 text_black">
            {{
            addMerFrom.lng ? addMerFrom.lng + "," + addMerFrom.lat : ""
            }}
          </span>
        </div>
        <div class="map_box u-f">
          <p class="lable u-f">
            <span class="font14 text_black">{{ $t("点击选择位置") }}：</span>
          </p>
          <el-amap
            ref="map"
            vid="amapDemo"
            :amap-manager="mapFrom.amapManager"
            :center="mapFrom.center"
            :zoom="mapFrom.zoom"
            :events="mapFrom.events"
            class="map"
          ></el-amap>
        </div>
        <div class="upload_list u-f">
          <p class="lable u-f">
            <span class="font14 text_black">{{ $t("商家") }}logo：</span>
          </p>
          <el-upload
            class="right"
            :action=" protocol + '//cdb.workair.vip/operate/screenadv/fileUpload'"
            :headers="{ token, ocode }"
            name="img_file"
            :data="{ type: 'image' }"
            :file-list="fileLogoList"
            :limit="1"
            :on-exceed="handleLogoExceed"
            :on-success="handleLogoSuccess"
            :on-remove="handleLogoRemove"
            :on-error="handleLogoError"
            list-type="picture"
          >
            <el-button size="small" type="primary">
              {{
              $t("点击上传")
              }}
            </el-button>
          </el-upload>
        </div>
        <div class="upload_list u-f">
          <p class="lable u-f">
            <span class="font14 text_black">{{ $t("商家图片") }}：</span>
          </p>
          <el-upload
            class="right"
            :action=" protocol + '//cdb.workair.vip/operate/screenadv/fileUpload'"
            :headers="{ token, ocode }"
            name="img_file"
            :data="{ type: 'image' }"
            :file-list="filePicList"
            :limit="1"
            :on-exceed="handlePicExceed"
            :on-success="handlePicSuccess"
            :on-remove="handlePicRemove"
            :on-error="handlePicError"
            list-type="picture"
          >
            <el-button size="small" type="primary">
              {{
              $t("点击上传")
              }}
            </el-button>
          </el-upload>
        </div>
        <div class="txt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("是否免押") }}：</span>
          </p>
          <el-radio-group v-model="addMerFrom.no_credit">
            <el-radio :label="1">{{ $t("不免押") }}</el-radio>
            <el-radio :label="0">{{ $t("免押") }}</el-radio>
          </el-radio-group>
        </div>
        <div class="txt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("离线推送") }}：</span>
          </p>
          <el-radio-group v-model="addMerFrom.offline_push">
            <el-radio :label="1">{{ $t("24小时推送") }}</el-radio>
            <el-radio :label="0">{{ $t("营业时间推送") }}</el-radio>
          </el-radio-group>
        </div>
        <!-- 10.25 新增跳单 -->
          <div class="ipts_list u-f u-f-ac" v-if="addMerFrom.no_credit == 0">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">押金单数：</span>
            </p>
            <span class="font14 text_black" style="margin-right: 10px" >
              每
            </span>
            <el-input style="width:80px;" v-model="addMerFrom.credit_ratio" :placeholder="$t('请输入')"></el-input>
            <span class="font14 text_black" style="margin-left: 10px" >
              单收取押金
            </span>
          </div>
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">风控类型：</span>
            </p>
            <el-radio-group v-model="addMerFrom.hidden_type">
              <el-radio :label="0">平台</el-radio>
              <el-radio :label="1">商户</el-radio>
            </el-radio-group>
          </div>
          <div class="ipts_list u-f u-f-ac" >
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">风控：</span>
            </p>
            <span class="font14 text_black" style="margin-right: 10px" >
              每
            </span>
            <el-input style="width:80px;" v-model="addMerFrom.hidden_ratio" :placeholder="$t('请输入')"></el-input>
            <span class="font14 text_black" style="margin-left: 10px" >
              单风控
            </span>
          </div>
 


        <div class="txt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("计费方式") }}：</span>
          </p>
          <el-radio-group v-model="addMerFrom.billing_mode" @change="handleBillingMode">
            <el-radio :label="1">{{ $t("系统默认") }}</el-radio>
            <el-radio :label="2">{{ $t("自定义") }}</el-radio>
          </el-radio-group>
        </div>
        <!-- 默认 -->
        <div v-if="addMerFrom.billing_mode == 1">
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">{{ $t("计费单位") }}：</span>
            </p>
            <span class="font14 text_black">
              {{
              addMerFrom.billing_unit == 1 ? $t("小时") : $t("分钟")
              }}
            </span>
          </div>
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">{{ $t("计费标准") }}：</span>
            </p>
            <span class="font14 text_black">
              {{ $t("每") }}{{ addMerFrom.billing_time
              }}{{ addMerFrom.billing_unit == 1 ? $t("小时") : $t("分钟")
              }}{{ $t("收费") }}{{ addMerFrom.amount }}{{ $t("元") }}
            </span>
          </div>
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">{{ $t("免费时长") }}：</span>
            </p>
            <span class="font14 text_black">{{ addMerFrom.freetime }}{{ $t("分钟") }}</span>
          </div>
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">{{ $t("当日内最高消费") }}：</span>
            </p>
            <span class="font14 text_black">{{ addMerFrom.ceiling }}{{ $t("元") }}</span>
          </div>
          <!-- <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">{{ $t("密码线") }}：</span>
            </p>
            <span
              class="font14 text_black"
              v-for="(item, index) in addMerFrom.wired_amount"
              :key="index"
            >{{ item.amount }}{{ $t("元") }}/{{ item.text }}；</span>
          </div> -->
        </div>
        <!-- 自定义 -->
        <div v-if="addMerFrom.billing_mode == 2">
          <div class="txt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">{{ $t("计费单位") }}：</span>
            </p>
            <el-radio-group v-model="addMerFrom.billing_unit" @input="billing_unit_Radio">
              <el-radio  :label="1">
                {{
                $t("小时")
                }}
              </el-radio>
              <!-- <el-radio  :label="2">
                {{
                $t("分钟")
                }}
              </el-radio> -->
            </el-radio-group>
          </div>

          <div class="ipts_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">{{ $t("计费标准") }}：</span>
            </p>

            <el-input v-model="addMerFrom.smaller" :placeholder="$t('请输入时长')"></el-input>

            <span class="font14 text_black" style="margin: 0 10px;">
              {{ addMerFrom.billing_unit == 1 ? $t("小时") : $t("分钟")
              }}{{ $t("收费") }}
            </span>

            <el-input v-model="addMerFrom.amount" :placeholder="$t('请输入金额')"></el-input>

            <span class="font14 text_black" style="margin-left: 10px;">
              {{
              $t("元")
              }}
            </span>

          </div>

          <div class="ipts_list u-f u-f-ac">

            <p class="lable u-f u-f-ac">
              <span class="font14 text_danger" style="margin-right: 3px;">*</span>
              <span class="font14 text_black">计费区间</span>
            </p>

            
          </div>
          
          <div v-for="(item,index) in billingData" style="margin-top: 5px;">
            <div style="display: flex;align-items: center;">
              <el-input style="width: 350px;" v-model="item.datetime" :placeholder="$t('请输入时长')"></el-input>
              
              <span style="margin-left: 10px;margin-right: 10px; "> - </span>

              <el-input style="width: 350px;" v-model="item.datetime1" :placeholder="$t('请输入时长')"></el-input>

              <span class="font14 text_black" style="margin: 0 10px;width: 80px;">
                {{ addMerFrom.billing_unit == 1 ? $t("小时") : $t("分钟")
                }}{{ $t("收费") }}
              </span>

              <el-input style="width: 350px;" v-model="item.amount" :placeholder="$t('请输入金额')"></el-input>

              <span class="font14 text_black" style="margin-left: 10px;">
                {{
                $t("元")
                }}
              </span>
            </div>
          </div>


          <div style="display: flex;justify-content: center;margin-bottom: 10px;margin-top: 10px;">
            <el-button @click="addBilling">+</el-button>
            <el-button @click="jianBilling">-</el-button>
          </div>
          


          <div class="ipt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">{{ $t("免费时长") }}：</span>
            </p>
            <el-input v-model="addMerFrom.freetime" :placeholder="$t('请输入免费时长')"></el-input>
            <span class="tip font14 text_danger">
              {{ $t("用户每次租借前多少分钟免费") }},{{
              $t("填0或者为空表示不免费")
              }},{{ $t("可输入") }}0-60
            </span>
          </div>
          <!-- <div class="ipt_list u-f u-f-ac">
            <p class="lable u-f u-f-ac">
              <span class="font14 text_black">{{ $t("每日最高消费") }}：</span>
            </p>
            <el-input v-model="addMerFrom.ceiling" :placeholder="$t('请输入每日最高消费')"></el-input>
            <span class="tip font14 text_danger">
              {{ $t("每日最高消费限额") }},{{
              $t("超出时长按照此金额来算")
              }},{{ $t("填0或者为空表示不限制") }}
            </span>
          </div> -->
          <!-- <div class="ipt_long_list u-f">
            <p class="lable u-f">
              <span class="font14 text_black">{{ $t("密码线") }}：</span>
            </p>
            <div class="right u-f u-fw">
              <div
                class="item u-f u-f-ac"
                v-for="(item, index) in addMerFrom.wired_amount"
                :key="index"
              >
                <el-input v-model="item.amount"></el-input>
                <span class="font14 text_black">{{ $t("元") }}/{{ item.text }}</span>
              </div>
            </div>
          </div> -->
        </div>
        <!--  -->
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("店铺电话") }}：</span>
          </p>
          <el-input v-model="addMerFrom.tel" :placeholder="$t('请输入店铺电话')"></el-input>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("营业时间") }}：</span>
          </p>
          <el-time-select
            v-model="addMerFrom.start_time"
            :picker-options="{
              start: '00:00',
              step: '00:10',
              end: '24:00',
            }"
            :placeholder="$t('开始时间')"
          ></el-time-select>
          <el-time-select
            class="m-l2"
            v-model="addMerFrom.end_time"
            :picker-options="{
              start: '00:00',
              step: '00:10',
              end: '24:00',
            }"
            :placeholder="$t('结束时间')"
          ></el-time-select>
        </div>
        <div class="ipt_list u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_black">{{ $t("人均消费") }}：</span>
          </p>
          <el-input v-model="addMerFrom.average_price" :placeholder="$t('请输入人均消费')"></el-input>
        </div>
        <div class="select_box u-f u-f-ac">
          <p class="lable u-f u-f-ac">
            <span class="font14 text_danger" style="margin-right: 3px;">*</span>
            <span class="font14 text_black">{{ $t("选择状态") }}：</span>
          </p>
          <el-select v-model="statusVal" :placeholder="$t('请选择')" @change="addMerStatusChange">
            <el-option
              v-for="item in statusArr"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>

        <button
          class="sub_btn font14 text_white bg_blue"
          @click="addSubmit"
          v-if="!updateCab"
        >{{ $t("提交") }}</button>
        <button
          class="sub_btn font14 text_white bg_blue"
          @click="updateSubmit"
          v-if="updateCab"
        >{{ $t("修改") }}</button>
      </div>
    </el-dialog>

    <!-- 租借统计 -->
    <el-dialog
      width="900px"
      :title="$t('租借统计')"
      :visible.sync="showStatistics"
      :close-on-click-modal="false"
    >
      <div class="kolea u-f">
        <ul class="u-f1">
          <li class="li font16 text_black">{{$t('今天租借次数')}}：{{ stat_num.today }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('昨天租借次数')}}：{{ stat_num.yesterday }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('本周租借次数')}}：{{ stat_num.week }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('上周租借次数')}}：{{ stat_num.lastWeek }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('本月租借次数')}}：{{ stat_num.month }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('上月租借次数')}}：{{ stat_num.lastMonth }}{{$t('次')}}</li>
          <li class="li font16 text_black">{{$t('累计租借次数')}}：{{ stat_num.total }}{{$t('次')}}</li>
        </ul>
        <ul class="u-f1">
          <li class="li font16 text_black">{{$t('今天订单金额')}}：{{ stat_amount.today }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('昨天订单金额')}}：{{ stat_amount.yesterday }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本周订单金额')}}：{{ stat_amount.week }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上周订单金额')}}：{{ stat_amount.lastWeek }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本月订单金额')}}：{{ stat_amount.month }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上月订单金额')}}：{{ stat_amount.lastMonth }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('累计订单金额')}}：{{ stat_amount.total }}{{$t('元')}}</li>
        </ul>
      </div>
      <div class="kolea u-f">
        <ul class="u-f1">
          <li class="li font16 text_black">{{$t('今天订单实收金额')}}：{{ stat_pay_amount.today }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('昨天订单实收金额')}}：{{ stat_pay_amount.yesterday }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本周订单实收金额')}}：{{ stat_pay_amount.week }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上周订单实收金额')}}：{{ stat_pay_amount.lastWeek }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本月订单实收金额')}}：{{ stat_pay_amount.month }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上月订单实收金额')}}：{{ stat_pay_amount.lastMonth }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('累计订单实收金额')}}：{{ stat_pay_amount.total }}{{$t('元')}}</li>
        </ul>
        <ul class="u-f1">
          <li class="li font16 text_black">{{$t('今天订单实收退款')}}：{{ stat_pay_refund.today }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('昨天订单实收退款')}}：{{ stat_pay_refund.yesterday }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本周订单实收退款')}}：{{ stat_pay_refund.week }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上周订单实收退款')}}：{{ stat_pay_refund.lastWeek }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('本月订单实收退款')}}：{{ stat_pay_refund.month }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('上月订单实收退款')}}：{{ stat_pay_refund.lastMonth }}{{$t('元')}}</li>
          <li class="li font16 text_black">{{$t('累计订单实收退款')}}：{{ stat_pay_refund.total }}{{$t('元')}}</li>
        </ul>
        
      </div>
      <div class="kolea u-f">
        <ul class="u-f1">
          <li class="li font16 text_black">{{ $t('今天租借率') }}：{{ dayrent }}{{ $t('%') }}</li>
          <li class="li font16 text_black">{{ $t('本周租借率') }}：{{ weekrent }}{{ $t('%') }}</li>
          <li class="li font16 text_black">{{ $t('本月租借率') }}：{{ rent }}{{ $t('%') }}</li>
        </ul>
      </div>
    </el-dialog>

    <agent-list ref="agentList" :memusid="memusid" :uid="uid" @hide="closeAgentList"></agent-list>
    <manage-list ref="manageList" :type="manageType" :memusid="memusid" :uid="uid" @hide="closeManageList"></manage-list>
    <refresh @click="handleRefresh"></refresh>
  </div>
</template>

<script>
import agentList from "components/agent-list/agent-list.vue";
import manageList from "components/manage-list/manage-list.vue";
import { regionData, CodeToText } from "element-china-area-data";
import { AMapManager } from "vue-amap";
import { mapState, mapMutations } from "vuex";
import VueAMap from "vue-amap";
let amapManager = new VueAMap.AMapManager();
import util from "@/assets/js/util.js";
export default {
  name: "seller-index",
  data() {
    let that = this;
    return {
      updateSpecial: false,
      dayrent: 0,
      rent: 0,
      weekrent: 0,
      totalSpecial: 0,
      tableDataSpecial: [],
      page: 1,
      page_size: 20,
      cabSpecial: false,
      addSpecialData: {
        id: "",
        battery_free: "",
        // battery_use: "",
        per_hour:"",
        manage: "",
        seller_id:"",
        member_id: "",//会员id
      },
      total: 0,
      protocol: window.location.protocol,
      merchant: "",
      address: "",
      clientVal: 0,
      clientArr: [
        {
          value: 0,
          label: that.$t("选择状态")
        },
        {
          value: 1,
          label: that.$t("正常")
        },
        {
          value: 2,
          label: that.$t("禁用")
        }
      ],
      salesmanVal: 0,
      salesmanArr: [
        {
          id: 0,
          name: that.$t("选择业务员")
        }
      ],
      manageType: 1,
      agent: "",
      agent_id: "",
      manage: "",
      manage_id: "",
      tableData: [],
      updateCab: false,
      showAddCab: false,
      showStatistics: false,
      regionArr: regionData,
      fileLogoList: [],
      filePicList: [],
      addMerFrom: {
        id: "",
        merchant: "",
        manage: "",
        manage_id: "",
        manage_rate: "",
        brokerage_rate: "",
        brokerage_show: '',
        agent: "",
        agent_id: "",
        agent_rate: "",
        salesman: "",
        salesman_id: "",
        salesman_rate: "",
        logo: "",
        picture: "",
        areaCode: ["440000", "440300", "440305"],
        area: "广东省深圳市南山区",
        address: "",
        lng: "113.923552",
        lat: "22.528499",
        no_credit: 1, // 1 不免押  0 免押
        offline_push: 0,//营业时间推送
        hidden_type: 0,  //风控类型
        billing_mode: 1, // 1 系统默认  2 自定义
        billing_unit: 1, // 1 小时  2 分钟
        billing_time: "1",
        credit_ratio: '',
        hidden_ratio: '',
        smaller:'1',
        amount: "1",
        freetime: "5",
        ceiling: "99.00",
        wired_amount: [
          { time: 1, text: "1小时", amount: "2" },
          { time: 2, text: "2小时", amount: "3" },
          { time: 3, text: "3小时", amount: "4" },
          { time: 4, text: "4小时", amount: "5" },
          { time: 5, text: "5小时", amount: "6" },
          { time: 6, text: "6小时", amount: "7" },
          { time: 12, text: "12小时", amount: "12" }
        ],
        tel: "",
        start_time: "",
        end_time: "",
        average_price: "",
        billing_data:[],
      },
      statusVal: 1,
      statusArr: [
        {
          value: 1,
          label: that.$t("正常")
        },
        {
          value: 2,
          label: that.$t("禁用")
        }
      ],
      mapFrom: {
        amapManager,
        zoom: 15,
        center: [113.923552, 22.528499],
        events: {
          click: e => {
            let cen = [e.lnglat.lng, e.lnglat.lat];
            that.mapFrom.center = cen;
            that.addMerFrom.lng = e.lnglat.lng;
            that.addMerFrom.lat = e.lnglat.lat;
            that.getAdress(cen);
          }
        }
      },
      stat_num: {},
      stat_amount: {},
      stat_pay_amount: {},
      stat_pay_refund: {},
      billingData: [
        {'datetime': '','datetime1':'','amount': 0},
      ],
      smaller: 0,

    };
  },
  computed: {
    ...mapState(["token", "ocode", "permissions", "menu", "memusid", "uid",])
  },
  components: {
    agentList,
    manageList
  },
  mounted() {

    if(this.memusid == 5){
      this.daili = false;
      
      this.agent_id = this.uid;
      this.agent = this.name;
      this.addMerFrom.agent_id = this.uid;
      this.addMerFrom.agent = this.name;
      // this.bindAgentFrom.agent_name = "请选择代理商";
      // this.aid = this.uid;
      // console.log("打印一下this.aid")
      // console.log(this.aid);
      // this.agent = this.name;
    }else if(this.memusid == 6){
      this.daili = false;
      this.shangjia = false;
      // this.bindAgentFrom.merchant_id = this.uid;
      this.addMerFrom.manage_id = this.uid;
      // this.getAgentData()
      this.manage_id = this.uid;
      // this.merchant = this.name;
    }

    this.getData();
    // addMerFrom
  },
  methods: {
    ...mapMutations(['setActiveMenu', 'setMenuArray', 'addKeepAlive']),
    handleRefresh() {
      this.page = 1
      this.page_size = 20
      this.merchant = ''
      this.address = ''
      this.clientVal = 0
      this.agent_id = ''
      this.agent = ''
      this.salesmanVal = 0
      this.manage_id = ''
      this.manage = ''
      this.getData()
    },
    addBilling(){
      var billingData2 = this.billingData;

      billingData2.push({'datetime': '','datetime1':'','amount': ''});
    
      this.billingData = billingData2;
    },
    jianBilling(){
      var billingData2 = this.billingData;

      billingData2.pop();
    
      this.billingData = billingData2;
    },
    getData(type) {
      if(type == 'search') { this.page = 1 }
      util
        .$http("/seller/index?page=" + this.page, {
          page_size: this.page_size,
          name: this.merchant,
          area: this.address,
          status: this.clientVal,
          agency_id: this.agent_id,
          agency_name: this.agent,
          employee_id: this.salesmanVal,
          manager_id: this.manage_id,
          manager_name: this.manage
        })
        .then(res => {
          if (res.code == 1) {
            this.total = res.data.total;
            this.tableData = res.data.list;
          }
        });
    },
    getDataTeshu(){
      
      // if(type == 'search') { this.page = 1 }
      util
        .$http("/special/specialList", {
          page_size: this.page_size,
          sid: this.addSpecialData.seller_id,
        })
        .then(res => {
          if (res.code == 1) {
            // console.log(res);
            // console.log("打印res");
            this.totalSpecial = res.data.total;
            this.tableDataSpecial = res.data.list;
            // console.log(this.tableDataSpecial);
          }
        });
    },
    clientChange(val) {
      this.clientVal = val;
    },
    salesmanChange(val) {
      this.salesmanVal = val;
    },
    openAgentList() {
      this.$refs.agentList.show();
    },
    closeAgentList(data) {
      let employArr = [
        {
          id: 0,
          name: this.$t("选择业务员")
        }
      ];
      this.agent_id = data.id;
      this.agent = data.name;
      this.getEmployee(data.id, res => {
        this.salesmanArr = [...employArr, ...res];
        this.salesmanVal = 0;
      });
    },
    clearAgent() {
      this.agent_id = "";
      this.agent = "";
      if(this.memusid == 5){
        this.agent_id = this.uid;
        this.agent = this.name;
      }
      this.salesmanArr = [
        {
          id: 0,
          name: this.$t("选择业务员")
        }
      ];
      this.salesmanVal = 0;
    },
    getEmployee(id, callback) {
      util
        .$http("/seller/employeeList", {
          id
        })
        .then(res => {
          if (res.code == 1) {
            callback(res.data);
          }
        });
    },
    openManageList(type) {
      this.manageType = type;
      this.$refs.manageList.show();
    },
    closeManageList(data, type) {
      if (type == 1) {
        this.manage_id = data.id;
        this.manage = data.name;
      } else if (type == 2) {
        this.addMerFrom.manage_id = data.id;
        this.addMerFrom.manage = data.name;
        this.getAgency(data.id, res => {
          this.addMerFrom.agent = res.agency_name;
          this.addMerFrom.agent_id = res.agency_id;
          this.addMerFrom.agent_rate = res.agency_brokerage;
          this.addMerFrom.salesman = res.employee_name;
          this.addMerFrom.salesman_id = res.employee_id;
          this.addMerFrom.salesman_rate = res.employee_brokerage;
        });
      }else if(type==4){
        // this.addMerFrom.manage_id = data.id;
        // this.addMerFrom.manage = data.name;
        this.addSpecialData.manage = data.name;
        this.addSpecialData.seller_id = data.id;
      }
    },
    
    clearManage(type) {
      if (type == 1) {
        this.manage_id = "";
        this.manage = "";
        
      } else if (type == 2) {
        this.addMerFrom.manage_id = "";
        this.addMerFrom.manage = "";
        this.addMerFrom.agent = "";
        this.addMerFrom.agent_id = "";
        this.addMerFrom.agent_rate = "";
        this.addMerFrom.salesman = "";
        this.addMerFrom.salesman_id = "";
        this.addMerFrom.salesman_rate = "";
        //判断一下
        if(this.memusid==5){
          this.addMerFrom.agent = this.agent;
          this.addMerFrom.agent_id = this.agent_id;
        }

      }else if(type == 4){
        this.addSpecialData.manage = "";
        this.addSpecialData.seller_id = "";
      }
    },
    getAgency(id, callback) {
      util
        .$http("/seller/agencyData", {
          id
        })
        .then(res => {
          if (res.code == 1) {
            callback(res.data);
          }
        });
    },
    addCabinet() {
      this.addMerFrom = {
        id: "",
        merchant: "",
        manage: "",
        manage_id: "",
        manage_rate: "",
        brokerage_rate: "",
        brokerage_show: '',
        agent: "",
        agent_id: "",
        agent_rate: "",
        salesman: "",
        salesman_id: "",
        salesman_rate: "",
        logo: "",
        picture: "",
        areaCode: ["440000", "440300", "440305"],
        area: "广东省深圳市南山区",
        address: "",
        lng: "113.923552",
        lat: "22.528499",
        no_credit: 1,
        offline_push: 0,
         hidden_type: 0, //风控类型
        billing_mode: 1, // 1 系统默认  2 自定义
        billing_unit: 1, // 1 小时  2 分钟
        billing_time: "1",
        credit_ratio: '',
        hidden_ratio: '',
        smaller:'1',
        amount: "1",
        freetime: "5",
        ceiling: "99.00",
        wired_amount: [
          { time: 1, text: "1小时", amount: "2" },
          { time: 2, text: "2小时", amount: "3" },
          { time: 3, text: "3小时", amount: "4" },
          { time: 4, text: "4小时", amount: "5" },
          { time: 5, text: "5小时", amount: "6" },
          { time: 6, text: "6小时", amount: "7" },
          { time: 12, text: "12小时", amount: "12" }
        ],
        tel: "",
        start_time: "",
        end_time: "",
        average_price: ""
      };
      this.statusVal = 1;
      this.fileLogoList = [];
      this.filePicList = [];
      this.updateCab = false;
      this.showAddCab = true;
      util
        .$http("/seller/detail", {
          id: 0
        })
        .then(res => {
          if (res.code == 1) {
            this.addMerFrom.billing_unit = Number(
              res.data.billing_sys.billingunit
            );
            this.addMerFrom.billing_time = res.data.billing_sys.billingtime;
            this.addMerFrom.amount = res.data.billing_sys.amount;
            this.addMerFrom.freetime = res.data.billing_sys.freetime;
            this.addMerFrom.ceiling = res.data.billing_sys.ceiling;
            this.addMerFrom.wired_amount = res.data.billing_sys.wired_amount;
            this.addMerFrom.smaller = res.data.billing_sys.smaller;
          }
        });
    },
    addSpecial(row){
      // console.log("打印一下啊");
      this.addSpecialData.seller_id = row.id;
      this.getDataTeshu();
      // console.log(row);

      // setTimeout(() => {
        this.cabSpecial = true;  
      // }, 200);

      
      
    },
    handleAreaChange(val) {
      let str = "";
      for (let item of val) {
        str += CodeToText[item];
      }
      this.addMerFrom.areaCode = val;
      this.addMerFrom.area = str;
      this.geoCode(str);
    },
    enterAddress(val) {
      this.geoCode(this.addMerFrom.area + val);
    },
    handleLogoSuccess(response) {
      this.addMerFrom.logo = response.msg;
    },
    handleLogoRemove() {
      this.addMerFrom.logo = "";
    },
    handleLogoError(err) {
      this.$message({
        message: this.$t("上传失败"),
        type: "warning"
      });
    },
    handleLogoExceed() {
      this.$message({
        message: this.$t("只能上传一张"),
        type: "warning"
      });
    },
    handlePicSuccess(response) {
      this.addMerFrom.picture = response.msg;
    },
    handlePicRemove() {
      this.addMerFrom.picture = "";
    },
    handlePicError(err) {
      this.$message({
        message: this.$t("上传失败"),
        type: "warning"
      });
    },
    handlePicExceed() {
      this.$message({
        message: this.$t("只能上传一张"),
        type: "warning"
      });
    },
    addSubmitSpecial() {
      util
        .$http("/Special/add", {
          battery_free: this.addSpecialData.battery_free,
          // per_hour: this.addSpecialData.per_hour,
          // battery_use:this.addSpecialData.battery_use,
          manage: this.addSpecialData.manage,
          member_id: this.addSpecialData.member_id,
          seller_ids:this.addSpecialData.seller_id
        })
        .then(res => {
          // console.log("打印一下res");
          // console.log(res)
          if (res.code == 1) {
            this.$message({
              message: res.msg,
              type: "success"
            });
            // console.log("走到这里了吗？？")
            this.addSpecialData.battery_free="";
          // per_hour: this.addSpecialData.per_hour,
            this.addSpecialData.id="";
            // this.addSpecialData.battery_use="";
            this.addSpecialData.manage="";
            this.addSpecialData.member_id="";
            // this.addSpecialData.seller_id="";
            this.getDataTeshu();
          }else{
            this.$message({
              message: res.msg,
              type: "warning"
            });
          }
        }
        )
    },
    addSubmit() {
      util
        .$http("/seller/add", {
          name: this.addMerFrom.merchant,
          manager_id: this.addMerFrom.manage_id,
          agency_id: this.addMerFrom.agent_id,
          employee_id: this.addMerFrom.salesman_id,
          employee_brokerage: this.addMerFrom.salesman_rate,
          brokerage: this.addMerFrom.manage_rate,
          brokerage_rate: this.addMerFrom.brokerage_rate,
          brokerage_show: this.addMerFrom.brokerage_show,
          logo: this.addMerFrom.logo,
          picture: this.addMerFrom.picture,
          province_code: this.addMerFrom.areaCode[0],
          city_code: this.addMerFrom.areaCode[1],
          district_code: this.addMerFrom.areaCode[2],
          area: this.addMerFrom.area,
          address: this.addMerFrom.address,
          longitude: this.addMerFrom.lng,
          latitude: this.addMerFrom.lat,
          no_credit: this.addMerFrom.no_credit,
          offline_push: this.addMerFrom.offline_push,
          hidden_type: this.addMerFrom.hidden_type,
          credit_ratio: this.addMerFrom.credit_ratio,
          hidden_ratio: this.addMerFrom.hidden_ratio,
          billing_type: this.addMerFrom.billing_mode,
          billingunit: this.addMerFrom.billing_unit,
          billingtime: this.addMerFrom.billing_time,
          smaller:this.addMerFrom.smaller,
          amount: this.addMerFrom.amount,
          freetime: this.addMerFrom.freetime,
          ceiling: this.addMerFrom.ceiling,
          wireds: JSON.stringify(this.addMerFrom.wired_amount),
          tel: this.addMerFrom.tel,
          shop_start: this.addMerFrom.start_time,
          shop_end: this.addMerFrom.end_time,
          average_price: this.addMerFrom.average_price,
          status: this.statusVal,
          billing_data: JSON.stringify(this.billingData)
        })
        .then(res => {
          if (res.code == 1) {
            this.$message({
              message: res.msg,
              type: "success"
            });
            this.updateCab = false;
            this.showAddCab = false;
            this.getData();
            this.addMerFrom = {
              id: "",
              merchant: "",
              manage: "",
              manage_id: "",
              manage_rate: "",
              brokerage_rate: "",
              brokerage_show: '',
              agent: "",
              agent_id: "",
              agent_rate: "",
              salesman: "",
              salesman_id: "",
              salesman_rate: "",
              logo: "",
              picture: "",
              areaCode: ["440000", "440300", "440305"],
              area: "广东省深圳市南山区",
              address: "",
              lng: "113.923552",
              lat: "22.528499",
              no_credit: 1,
              offline_push: 0,
              hidden_type: 0,
              billing_mode: 1, // 1 系统默认  2 自定义
              billing_unit: 1, // 1 小时  2 分钟
              billing_time: "1",
              credit_ratio: '',
              hidden_ratio: '',
              smaller: '1',
              amount: "1",
              freetime: "5",
              ceiling: "99.00",
              wired_amount: [
                { time: 1, text: "1小时", amount: "2" },
                { time: 2, text: "2小时", amount: "3" },
                { time: 3, text: "3小时", amount: "4" },
                { time: 4, text: "4小时", amount: "5" },
                { time: 5, text: "5小时", amount: "6" },
                { time: 6, text: "6小时", amount: "7" },
                { time: 12, text: "12小时", amount: "12" }
              ],
              tel: "",
              start_time: "",
              end_time: "",
              average_price: ""
            };
            this.statusVal = 1;
            this.fileLogoList = [];
            this.filePicList = [];
          }
        });
    },
    updateSubmit() {
      if(!this.addMerFrom.areaCode[0] || !this.addMerFrom.areaCode[1] || !this.addMerFrom.areaCode[2]) {
        this.$message({
          message: this.$t("请重新选择所在区域"),
          type: "warning"
        });
        return
      }
      console.log("分成系数比")
      console.log(this.addMerFrom.brokerage_rate)
      // return false;
      util
        .$http("/seller/edit", {
          id: this.addMerFrom.id,
          name: this.addMerFrom.merchant,
          manager_id: this.addMerFrom.manage_id,
          agency_id: this.addMerFrom.agent_id,
          employee_id: this.addMerFrom.salesman_id,
          employee_brokerage: this.addMerFrom.salesman_rate,
          brokerage: this.addMerFrom.manage_rate,
          brokerage_rate:Number(this.addMerFrom.brokerage_rate),
          brokerage_show: this.addMerFrom.brokerage_show,
          logo: this.addMerFrom.logo,
          picture: this.addMerFrom.picture,
          province_code: this.addMerFrom.areaCode[0],
          city_code: this.addMerFrom.areaCode[1],
          district_code: this.addMerFrom.areaCode[2],
          area: this.addMerFrom.area,
          address: this.addMerFrom.address,
          longitude: this.addMerFrom.lng,
          latitude: this.addMerFrom.lat,
          no_credit: this.addMerFrom.no_credit,
          offline_push: this.addMerFrom.offline_push,
          hidden_type: this.addMerFrom.hidden_type,
          billing_type: this.addMerFrom.billing_mode,
          billingunit: this.addMerFrom.billing_unit,
          billingtime: this.addMerFrom.billing_time,
          credit_ratio: this.addMerFrom.credit_ratio,
          hidden_ratio: this.addMerFrom.hidden_ratio,
          amount: this.addMerFrom.amount,
          smaller:this.addMerFrom.smaller,
          freetime: this.addMerFrom.freetime,
          ceiling: this.addMerFrom.ceiling,
          wireds: JSON.stringify(this.addMerFrom.wired_amount),
          tel: this.addMerFrom.tel,
          shop_start: this.addMerFrom.start_time,
          shop_end: this.addMerFrom.end_time,
          average_price: this.addMerFrom.average_price,
          status: this.statusVal,
          billing_data: JSON.stringify(this.billingData)
        })
        .then(res => {
          if (res.code == 1) {
            this.$message({
              message: res.msg,
              type: "success"
            });
            this.updateCab = false;
            this.showAddCab = false;
            this.getData();
            this.addMerFrom = {
              id: "",
              merchant: "",
              manage: "",
              manage_id: "",
              manage_rate: "",
              brokerage_rate: "",
              brokerage_show: '',
              agent: "",
              agent_id: "",
              agent_rate: "",
              salesman: "",
              salesman_id: "",
              salesman_rate: "",
              logo: "",
              picture: "",
              areaCode: ["440000", "440300", "440305"],
              area: "广东省深圳市南山区",
              address: "",
              lng: "113.923552",
              lat: "22.528499",
              no_credit: 1,
              offline_push: 0,
              hidden_type: 0,
              billing_mode: 1, // 1 系统默认  2 自定义
              billing_unit: 1, // 1 小时  2 分钟
              billing_time: "1",
              credit_ratio: '',
              hidden_ratio: '',
              smaller: '1',
              amount: "1",
              freetime: "5",
              ceiling: "99.00",
              wired_amount: [
                { time: 1, text: "1小时", amount: "2" },
                { time: 2, text: "2小时", amount: "3" },
                { time: 3, text: "3小时", amount: "4" },
                { time: 4, text: "4小时", amount: "5" },
                { time: 5, text: "5小时", amount: "6" },
                { time: 6, text: "6小时", amount: "7" },
                { time: 12, text: "12小时", amount: "12" }
              ],
              tel: "",
              start_time: "",
              end_time: "",
              average_price: ""
            };
            this.statusVal = 1;
            this.fileLogoList = [];
            this.filePicList = [];
          }
        });
    },
    handleCurrentChange(val) {
      this.page = Number(val);
      this.getData();
    },
    deviceDetail(row) {
      this.recursion('/equipment/index', this.menu, row)
    },
    recursion(path, arr, data) {
      for(let item of arr){
        if(!item.children){
          if(item.index == path) {
            this.setMenuArray(item)
            this.setActiveMenu(item)
            this.addKeepAlive('equipment-index')
            this.$router.push({ path, query: { merchant: data.name, merchant_id: data.id }})
          }
        }else{
          this.recursion(path, item.children, data)
        }
      }
    },
    
    updateDevice(row) {
      this.updateCab = true;
      this.showAddCab = true;
      this.fileLogoList = [];
      this.filePicList = [];
      this.statusVal = 1;
      setTimeout(() => {
        util
        .$http("/seller/detail", {
          id: row.id
        })
        .then(res => {
          if (res.code == 1) {
            if(!res.data.province_code || !res.data.city_code || !res.data.district_code) {
              this.$confirm(this.$t("请重新选择所在区域"))
              .then(()=>{})
              .catch(()=>{})
            }
            this.addMerFrom = {
              id: res.data.id,
              merchant: res.data.name,
              manage: res.data.manager_name,
              manage_id: res.data.manager_id,
              manage_rate: res.data.brokerage,
              brokerage_rate: res.data.brokerage_rate,
              brokerage_show: res.data.brokerage_show,
              agent: res.data.agency_name,
              agent_id: res.data.agency_id,
              agent_rate: res.data.agency_brokerage,
              salesman: res.data.employee_name,
              salesman_id: res.data.employee_id,
              salesman_rate: res.data.employee_brokerage,
              logo: res.data.logo,
              picture: res.data.picture,
              areaCode: [
                res.data.province_code ? res.data.province_code.toString() : '',
                res.data.city_code ? res.data.city_code.toString() : '',
                res.data.district_code ? res.data.district_code.toString() : ''
              ],
              area: res.data.area,
              address: res.data.address,
              lng: res.data.longitude,
              lat: res.data.latitude,
              no_credit: Number(res.data.no_credit),
              offline_push: Number(res.data.offline_push),
              hidden_type: Number(res.data.hidden_type),
              billing_mode: Number(res.data.billing_type), // 1 系统默认  2 自定义
              billing_unit: Number(res.data.billingunit), // 1 小时  2 分钟
              billing_time: res.data.billingtime,
              credit_ratio: res.data.credit_ratio,
              hidden_ratio: res.data.hidden_ratio,
              smaller: res.data.smaller,
              amount: res.data.amount,
              freetime: res.data.freetime,
              ceiling: res.data.ceiling,
              wired_amount: res.data.wired_amount,
              tel: res.data.tel,
              start_time: res.data.shop_start,
              end_time: res.data.shop_end,
              average_price: res.data.average_price,
              billing_data: res.data.billingall,
            };
            // console.log("查询一下怎么是");
            // console.log(res.data);
            //判断一下是否有区间数据
            // if()
            this.billingData = res.data.billingall;
            if(this.billingData==undefined){
              this.billingData = [
                {'datetime': '','datetime1':'','amount': 0},
              ];
            }
            this.statusVal = Number(res.data.status);
            if (res.data.logo && res.data.logo != "0") {
              this.fileLogoList = [
                {
                  name: 1,
                  url: res.data.logo
                }
              ];
            }
            if (res.data.picture && res.data.picture != "0") {
              this.filePicList = [
                {
                  name: 1,
                  url: res.data.picture
                }
              ];
            }
          }
        });
      }, 150);
    },
    statistics(row) {
      this.showStatistics = true;
      setTimeout(() => {
        util
        .$http("/seller/trend", {
          id: row.id
        })
        .then(res => {
          if (res.code == 1) {
            this.stat_num = res.data.num;
            this.stat_amount = res.data.amount;
            this.stat_pay_amount = res.data.pay_amount;
            this.stat_pay_refund = res.data.pay_refund;
            this.dayrent = res.data.rentday;
            this.weekrent = res.data.rentweek;
            this.monthrent = res.data.rent;
          }
        });
      }, 150);
    },
    guanbi(){
      this.addSpecialData.battery_free="";
      this.addSpecialData.id="";
      // this.addSpecialData.battery_use="";
      this.addSpecialData.manage="";
      this.addSpecialData.member_id="";
    },
    updateSubmitSpecial(){
      util
        .$http("/Special/update", {
          battery_free: this.addSpecialData.battery_free,
          // per_hour: this.addSpecialData.per_hour,
          id:this.addSpecialData.id,
          battery_use:0,
          manage: this.addSpecialData.manage,
          member_id: this.addSpecialData.member_id,
          seller_ids:this.addSpecialData.seller_id
        })
        .then(res => {
          // console.log("打印一下res");
          // console.log(res)
          if (res.code == 1) {
            this.$message({
              message: res.msg,
              type: "success"
            });
            this.addSpecialData.battery_free="";
          // per_hour: this.addSpecialData.per_hour,
            this.addSpecialData.id="";
            // this.addSpecialData.battery_use="";
            this.addSpecialData.manage="";
            this.addSpecialData.member_id="";
            // this.addSpecialData.seller_id="";
            this.getDataTeshu();
            this.updateSpecial = false;
          }else{
            this.$message({
              message: res.msg,
              type: "warning"
            });
          }
        }
        )
    },

    //修改特殊用户
    updateCanTab1(row){
      console.log("打印row");
      console.log(row);
      this.addSpecialData.battery_free = row.battery_free;
      // this.addSpecialData.battery_use = row.battery_use;
      // this.addSpecialData.manage = row.addSpecialData.nick,
      this.addSpecialData.member_id = row.member_id;
      this.addSpecialData.seller_id = row.sid;
      this.addSpecialData.id = row.id;

      this.updateSpecial = true;
    },

    deleteCanTab1(row){
      this.$confirm(this.$t("是否要删除当前用户"))
        .then(() => {
          util
            .$http("/special/delete", {
              id: row.id
            })
            .then(res => {
              if (res.code == 1) {
                this.$message({
                  message: res.msg,
                  type: "success"
                });
                this.getDataTeshu();
              }
            });
        })
        .catch(() => {});
    },

    deleteCanTab(row) {
      this.$confirm(this.$t("是否要删除当前商户"))
        .then(() => {
          util
            .$http("/seller/delete", {
              id: row.id
            })
            .then(res => {
              if (res.code == 1) {
                this.$message({
                  message: res.msg,
                  type: "success"
                });
                this.getData();
              }
            });
        })
        .catch(() => {});
    },
    geoCode(address) {
      AMap.plugin("AMap.Geocoder", () => {
        let geocoder = new AMap.Geocoder();
        geocoder.getLocation(address, (status, result) => {
          if (status === "complete" && result.geocodes.length) {
            let lnglat = result.geocodes[0].location;
            this.addMerFrom.lng = lnglat.lng;
            this.addMerFrom.lat = lnglat.lat;
            this.mapFrom.center = [lnglat.lng, lnglat.lat];
          }
        });
      });
    },
    getAdress(cen) {
      AMap.plugin("AMap.Geocoder", () => {
        let geocoder = new AMap.Geocoder();
        geocoder.getAddress(cen, (status, result) => {
          if (status === "complete" && result.regeocode) {
            let address = result.regeocode.formattedAddress;
            let areaCode = this.handleAreaCode(
              result.regeocode.addressComponent.adcode
            );
            this.addMerFrom.areaCode = areaCode;
            let obj = this.handleAddress(address);
            this.addMerFrom.area = obj.area;
            this.addMerFrom.address = obj.address;
          }
        });
      });
    },
    handleAreaCode(adcode) {
      let arr = [];
      let two = adcode.slice(0, 2);
      if (two == "81" || two == "82") {
        //香港和澳门
        arr[0] = adcode.slice(0, 2) + "0000";
        arr[1] = adcode;
      } else {
        arr[0] = adcode.slice(0, 2) + "0000";
        arr[1] = adcode.slice(0, 4) + "00";
        arr[2] = adcode;
      }
      return arr;
    },
    handleAddress(add5) {
      let reg = /.+?(省|市|自治区|自治州|县|区)/g;
      let areaArr = add5.match(reg);
      if (areaArr.length > 3) {
        areaArr = areaArr.splice(0, 3);
      }
      let area = "";
      for (let item of areaArr) {
        area += item;
      }
      let address = add5.substring(area.length);
      return { area, address };
    },
    handleBillingMode(val) {
      if (val == 1) {
        this.addMerFrom.billing_unit = 1;
        this.addMerFrom.billing_time = 1;
        this.addMerFrom.amount = "1";
        this.addMerFrom.freetime = "5";
        this.addMerFrom.ceiling = "99";
        this.addMerFrom.wired_amount = [
          { time: 1, text: "1小时", amount: "2" },
          { time: 2, text: "2小时", amount: "3" },
          { time: 3, text: "3小时", amount: "4" },
          { time: 4, text: "4小时", amount: "5" },
          { time: 5, text: "5小时", amount: "6" },
          { time: 6, text: "6小时", amount: "7" },
          { time: 12, text: "12小时", amount: "12" }
        ];
      }
    },
    addMerStatusChange(val) {
      this.statusVal = val;
    },
    // 10.25 计费单位radio 切换时回调
    billing_unit_Radio(e){
        let billingtime = e == 1 ? '1' : '30'
        // console.log(billingtime)
        this.addMerFrom.billing_time = billingtime
    }
  }
};
</script>

<style scoped>
.head_search {
  padding-bottom: 20px;
  margin-bottom: 20px;
}
.head_search .ipt_box {
  width: 280px;
  margin-right: 20px;
}
.head_search .ipt_box .el-input {
  width: 200px;
}
.head_search .select_box {
  width: 280px;
  margin-right: 20px;
}
.head_search .select_box .el-select {
  width: 200px;
}
.head_search .div_box {
  width: 320px;
  margin-right: 20px;
}
.head_search .div_box .content {
  width: 170px;
  height: 40px;
  padding-left: 15px;
  border: 1px solid #dcdfe6;
  border-radius: 4px 0 0 4px;
  transition: border 0.3s;
  box-sizing: border-box;
}
.head_search .div_box .content:active {
  border-color: #409eff;
}
.head_search .div_box .btn {
  width: 60px;
  height: 40px;
  border: 0;
  outline: 0;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  box-sizing: border-box;
}
.head_search .switch_box {
  width: 151px;
  margin-right: 20px;
}
.head_search .sub_btn {
  height: 40px;
  border: 0;
  outline: 0;
  padding: 0 21px;
  cursor: pointer;
  border-radius: 4px;
}
.head_tip {
  margin: 0 0 10px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #ebeef5;
}
.head_options .sub_btn {
  height: 34px;
  border: 0;
  outline: 0;
  padding: 0 15px;
  cursor: pointer;
  border-radius: 4px;
  margin-right: 20px;
}
.head_options .txt_list {
  font-weight: bold;
  margin-right: 25px;
}
.iconfont {
  font-size: 15px;
  margin-right: 5px;
}
.circle {
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border-radius: 100%;
}
.qrcode {
  cursor: pointer;
  margin: 0;
}
.cabinet_status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
}
.table_btn {
  cursor: pointer;
  padding: 7px 10px;
  border: 0;
  outline: 0;
  border-radius: 4px;
}
.pagination_box {
  padding-top: 30px;
}
.pagination_box .el-pagination {
  display: flex;
  justify-content: flex-end;
}
.order_detail {
  padding-left: 50px;
}
.order_detail .ipt_list {
  margin-bottom: 20px;
}
.order_detail .ipt_list .lable {
  width: 100px;
  margin: 0;
}
.order_detail .ipt_list .el-input {
  width: 400px;
}
.order_detail .el-input .el-input__inner {
  height: 36px;
  line-height: 36px;
}
.order_detail .ipt_list .el-textarea {
  width: 300px;
}
.order_detail .ipt_list .el-textarea__inner {
  min-height: 90px !important;
}
.order_detail .ipt_list .el-input.el-date-editor {
  width: 190px;
}
.order_detail .ipt_list .el-date-editor.m-l2 {
  margin-left: 20px;
}
.order_detail .ipt_list .tip {
  width: 300px;
  margin: 0 0 0 15px;
}
.order_detail .ipts_list {
  margin-bottom: 20px;
}
.order_detail .ipts_list .lable {
  width: 100px;
  margin: 0;
}
.order_detail .ipts_list .el-input {
  width: 150px;
}
.order_detail .ipt_long_list {
  margin-bottom: 20px;
}
.order_detail .ipt_long_list .lable {
  width: 100px;
  margin: 0;
}
.order_detail .ipt_long_list .right {
  width: 400px;
}
.order_detail .ipt_long_list .item {
  margin-right: 20px;
  margin-bottom: 10px;
}
.order_detail .ipt_long_list .el-input {
  width: 50px;
  margin-right: 5px;
}

.order_detail .txt_list {
  margin-bottom: 20px;
}
.order_detail .txt_list .lable {
  width: 100px;
  margin: 0;
}
.order_detail .txt_list .tip {
  width: 300px;
  margin: 0 0 0 15px;
}
.order_detail .upload_list {
  margin-bottom: 20px;
}
.order_detail .upload_list .lable {
  width: 100px;
  margin: 0;
}
.order_detail .upload_list .right {
  width: 400px;
}
.order_detail .select_box {
  margin-bottom: 20px;
}
.order_detail .select_box .lable {
  width: 100px;
  margin: 0;
}
.order_detail .select_box .el-select {
  width: 200px;
}
.order_detail .div_box {
  margin-bottom: 20px;
}
.order_detail .div_box .lable {
  width: 100px;
  margin: 0;
}
.order_detail .div_box .content {
  width: 340px;
  height: 40px;
  padding-left: 15px;
  border: 1px solid #dcdfe6;
  border-radius: 4px 0 0 4px;
  transition: border 0.3s;
  box-sizing: border-box;
}
.order_detail .div_box .content:active {
  border-color: #409eff;
}
.order_detail .div_box .btn {
  width: 60px;
  height: 40px;
  border: 0;
  outline: 0;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  box-sizing: border-box;
}
.order_detail .select_box {
  margin-bottom: 20px;
}
.order_detail .select_box .lable {
  width: 100px;
  margin: 0;
}
.order_detail .select_box .el-select {
  width: 170px;
}
.order_detail .map_box {
  margin-bottom: 20px;
}
.order_detail .map_box .lable {
  width: 100px;
  margin: 0;
}
.order_detail .map_box .map {
  width: 640px;
  height: 300px;
}
.order_detail .sub_btn {
  height: 40px;
  border: 0;
  outline: 0;
  padding: 0 25px;
  cursor: pointer;
  border-radius: 4px;
  margin-right: 20px;
  margin-left: 100px;
  margin-top: 20px;
}
.kolea ul {
  list-style: none;
  padding-left: 50px;
  box-sizing: border-box;
}
.kolea .li {
  margin-bottom: 10px;
}
</style>
